import collections


def maxSlidingWindow(nums, k):
    deque = collections.deque()
    res, n = [], len(nums)
    for i, j in zip(range(1 - k, n + 1 - k), range(n)):
        if i > 0 and deque[0] == nums[i - 1]:
            deque.popleft()
        while deque and deque[-1] < nums[j]:
            deque.pop()
        deque.append(nums[j])
        if i >= 0:
            res.append(deque[0])
    return res


s = input().split(" ")
n = int(s[0])
k = int(s[1])
nums = [int(x) for x in input().split(" ")]
print(maxSlidingWindow(nums, k))
